<h1><span></span><?= lang('label_menu_link_private_messages'); ?></h1>

<ul class="breadcrumb">
    <li><a href="<?= base_url() ?>"><?= lang('label_home') ?></a></li>
    <li><a href="<?= base_url('user/profile') ?>"><?= lang('label_profile') ?></a></li>
    <li><?= lang('label_menu_link_private_messages'); ?></li>
</ul>


<div class="page">

    <?php $this->load->view('template/default/private/top') ?>

    <div style="overflow:hidden;">

        <?php $this->load->view('template/default/private/side') ?>

        <div class="profile_page">
            <h2 class="profile_page_title"><?= lang('label_menu_link_private_messages'); ?> &raquo; <strong><?= lang("label_$ptype") ?></strong></h2>
            <?php if ($messages) { ?>
                <form action="<?php echo current_url() ?>/all/" method="post">
                    <table id="tablestyle">
                        <thead>
                            <tr>
                                <th><?= lang('label_subject') ?></th>
                                <th><?= lang('label_send_date') ?></th>
                                <?php if($ptype == 'outbox'){ ?>
                                <th><?= lang('label_seen_date') ?></th>
                                <?php } ?>
                                <th><?= lang('label_operation') ?></th>
                            </tr>
                        </thead>

                        <tbody>
                            <?php
                            foreach ($messages as $value) {
                                ?>
                                <tr <?php if ($ptype == 'inbox' && $value->seen == 'NO') { ?>style='background-color: #e8f9fd;'<?php } ?>>
                                    <td>
                                        <div class="checkbox">
                                            <a href="<?php echo base_url(get_segment(1) . "/view/$value->id") ?>"><?php echo $value->subject ?></a>
                                        </div>
                                    </td>
                                    <td><?= timespan($value->create_date) ?></td>
                                    <?php if($ptype == 'outbox'){ ?>
                                    <td><?= ($value->seen_date == '0000-00-00 00:00:00') ? lang('label_not_seen') : timespan($value->seen_date) ?></td>
                                    <?php } ?>
                                    <td><a href="<?php echo base_url(get_segment(1) . "/delete/$value->id"); ?>" id="confirm_delete" class="adelete"></a></td>
                                </tr>
                                <?php
                            }
                            ?>

                        </tbody>
                    </table>


                </form>
            <?php } else { ?>
                <div class="unsaved">
                    <img src="<?php echo str_replace('/index.php', '', $_SERVER['SCRIPT_NAME']) ?>/<?php echo APPPATH ?>views/<?php echo $this->themes->Cms_themes() ?>/images/unsaved.png" alt="" />
                    <br /><?= lang('message_no_messages_found') ?>
                </div>
                <br /><br /><br /><br />
            <?php } ?>
        </div>
    </div>
</div>
